;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-advanced-reader.ss" "lang")((modname midtermpractice) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ())))
(define-struct employee (name salary supervises))

(define give-raise (lambda( val )
    (cond [(< val  60000)
             (* val 1.1)]
          [else val])))

(define give-raises (lambda (employee)
    (make-employee 
       (employee-name employee)
       (give-raise (employee-salary employee))
       (map give-raises (employee-supervises employee)))))

(check-expect (give-raises 
    (make-employee "Bob" 100000 (list
       (make-employee "John" 50000 empty)
       (make-employee "Nican" 100000 (list 
             (make-employee "Intern Loser" 1000 empty)
             ))))) 
   
    (make-employee "Bob" 100000 (list
       (make-employee "John" (* 1.1 50000) empty)
       (make-employee "Nican" 100000 (list 
             (make-employee "Intern Loser" (* 1.1 1000) empty)
             )))))


(define get-none-below (lambda( employee-list)
    (cond [(empty? employee-list) empty]
          [(cons? employee-list)
             (append
               (none-below (first employee-list))
               (get-none-below (rest employee-list)))])))

(define none-below (lambda (employee)
    (cond [(empty? (employee-supervises employee)) 
         (cons (employee-name employee) empty)
           ]
         [else
          (get-none-below (employee-supervises employee))])))
           
(none-below (make-employee "Bob" 100000 (list
       (make-employee "John" (* 1.1 50000) empty)
       (make-employee "Nican" 100000 (list 
             (make-employee "Intern Loser" (* 1.1 1000) empty)
             )))))